import 'dart:convert';

import 'package:xuance/bean/HomeBlockIpBean.dart';
import 'package:xuance/bean/splunkDataBean.dart';
import 'package:xuance/network/network_service.dart';

class HomeApi {
  static Future<List<HomeBlockIpBean>> blockIp(
      {required String startTime,
      String? endTime,
      required String queryCondition}) async {
    var res = await NetworkService.post(
        url: "IpData/queryIpDataGroup",
        map: {
          "startDate": startTime,
          "endDate": endTime,
          "queryCondition": queryCondition
        },
        isShowLoading: false);
    return res.getTypedList<HomeBlockIpBean>(
            (m) => HomeBlockIpBean.fromJson(m)) ??
        [];
  }

  static Future<SplunkDataBean?> getSplunkData(
      {required String startTime,
      required String endTime,
      required int currentPage,
      required String riskLevelSort,
      required String createdTime,
      required String queryCondition}) async {
    var res = await NetworkService.post(
        url: "/splunk/querySplunkLogFlutterList",
        map: {
          "startDate": startTime,
          "endDate": endTime,
          "currentPage": currentPage,
          "pageSize": 10,
          "riskLevelSort": riskLevelSort,
          "createdTime": createdTime,
          "queryCondition": queryCondition,
        },
        isShowLoading: false);

    print(jsonEncode(res.data));
    return res.getTypedData((m) => SplunkDataBean.fromJson(m));
  }
}
